package com.bruce.spring.http.service;

import jakarta.servlet.FilterChain;
import jakarta.servlet.ServletException;
import jakarta.servlet.ServletRequest;
import jakarta.servlet.ServletResponse;
import jakarta.servlet.http.HttpFilter;
import jakarta.servlet.http.HttpServletRequest;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.stereotype.Component;

import java.io.IOException;
import java.io.Serial;

/**
 * Created by bruce in 2025/6/18 18:30
 */
@Component
public class AuthFilter extends HttpFilter {

    @Serial
    private static final long serialVersionUID = 8390294211450548630L;

    private static final Logger log = LoggerFactory.getLogger(AuthFilter.class);

    @Override
    public void doFilter(ServletRequest request, ServletResponse response, FilterChain chain) throws IOException, ServletException {
        HttpServletRequest req = (HttpServletRequest) request;
        String token = req.getHeader("my-token");
        // log.info("request token: {}", token);
        super.doFilter(request, response, chain);
        // System.out.println("response token");
    }

}
